package com.azusa.xbiao.dao;

import com.azusa.xbiao.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface UserDao extends JpaRepository<User,Integer> {

    User findByUsernameAndPassword(String username,String password);

    User findByEmail(String email);

    User findByUsername(String username);

    User findByUsernameAndEmail(String username,String email);

    User findByWxOpenid(String wx);

    /**
     * 修改默认地址
     * @param userId
     * @param aId
     * @param address
     * @return
     */
    @Query("update User set addressId=?2,address=?3 where id=?1")
    @Modifying
    int updateUserAddress(int userId,int aId,String address);
}
